#include<iostream>
using namespace std;
#define MAXSIZE 100
#define OK 1
#define ERROR 0
#define OVERFLOW -2

typedef struct {
	int* base;
	int* top;
	int stacksize;
}Stack;

int init(Stack& S) {
	S.base = new int[MAXSIZE];
	if (!S.base) exit(OVERFLOW);
	S.top = S.base;
	S.stacksize = MAXSIZE;
	return OK;
}

int push(Stack& S, int e) {
	if (S.top - S.base == S.stacksize)
		return ERROR;
	*S.top++ = e;
	return OK;
}

int pop(Stack& S, int& e) {
	if (S.base == S.top)
		return ERROR;
	e = *--S.top;
	return OK;
}

int main() {
	int n, a, b;
	Stack S;
	init(S);
	cin >> n;
	while (n--) {
		cin >> a;
		push(S, a);
	}
	while (*(S.base)) {
		pop(S, b);
		cout << b << " ";
	}
	return 0;
}